package com.icez.baseutil

import android.animation.ObjectAnimator
import android.animation.ValueAnimator.AnimatorUpdateListener


/**
 * Created by Fussen on 2017/4/21.
 */
class ChartAnimator(private val mListener: AnimatorUpdateListener) {
    /**
     * This gets the y-phase that is used to animate the values.
     *
     * @return
     */
    /**
     * This modifys the y-phase that is used to animate the values.
     *
     * @param phase
     */
    var phaseY = 1f //0f-1f
    /**
     * This gets the x-phase that is used to animate the values.
     *
     * @return
     */
    /**
     * This modifys the X-phase that is used to animate the values.
     *
     * @param phase
     */
    var phaseX = 1f //0f-1f

    /**
     * Y轴动画
     *
     * @param durationMillis
     */
    fun animateY(durationMillis: Int) {
        val animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f)
        animatorY.duration = durationMillis.toLong()
        animatorY.addUpdateListener(mListener)
        animatorY.start()
    }

    /**
     * X轴动画
     *
     * @param durationMillis
     */
    fun animateX(durationMillis: Int) {
        val animatorY = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f)
        animatorY.duration = durationMillis.toLong()
        animatorY.addUpdateListener(mListener)
        animatorY.start()
    }

}
